public class swapPairs { public ListNode swapPairs(ListNode head) {
    ListNode a = new ListNode(0);
    a.next = head;
    ListNode cur = a;
    while(cur.next != null && cur.next.next != null){
        ListNode first = cur.next;
        ListNode second = cur.next.next;
        cur.next = second;
        first.next = second.next;
        second.next = first;
        cur = first;
    }
    return a.next;
}
}
